<?php

namespace Database\Seeders;

use App\Models\Product;
use App\Models\ProductSku;
use App\Models\AttributeKey;
use App\Models\AttributeGroup;
use Illuminate\Database\Seeder;

class AttributeSeeder extends Seeder
{
    public function run()
    {
        AttributeGroup::create(['title' => '内裤']);
        
        AttributeKey::create(['attribute_group_id' => 1, 'key' => '颜色']);
        AttributeKey::create(['attribute_group_id' => 1, 'key' => '尺码']);
        AttributeKey::create(['attribute_group_id' => 1, 'key' => '材质']);
        
        Product::find(1)->update(['attribute_group_id' => 1]);
        
        $skuAttrValue = [1 => '黑色', 2 => 'M', 3 => '纯棉'];
        ProductSku::find(1)->update(['attr_value' => $skuAttrValue]);
        
        $skuAttrValue = [1 => '黑色', 2 => 'XL', 3 => '纯棉'];
	    ProductSku::find(2)->update(['attr_value' => $skuAttrValue]);
	    
        $skuAttrValue = [1 => '白色', 2 => 'M', 3 => '纯棉'];
	    ProductSku::find(3)->update(['attr_value' => $skuAttrValue]);
    }
}
